/**
 * Created by ying on 16-8-26.
 */
app.controller('cartCtrl', function($scope,$location) {
    $scope.cart = new Cart();
    $scope.show_count=function(){
        var count=$scope.cart.get_sum_count();
        $scope.sum_count=count ||0;
        if(count==0){
            $location.path('/product_list');
        }
    }
    $scope.show_money=function(){
        var sum_money=$scope.cart.get_sum_money();
        $scope.sum_money=sum_money.toFixed(2);
    }
    function show_sum_count_and_money(){
        $scope.show_count();
        $scope.show_money();
    }
    show_sum_count_and_money();
    $scope.informations=_.values($scope.cart.goods_info);
    $scope.judgment_subtotal=function(item){
        if(item.pro_count!=0){
            return true;
        }
    }
    $scope.add_click_event=function(item,num){
        $scope.cart.updata_goods_info(item,num);
        show_sum_count_and_money();
        $scope.informations=_.values($scope.cart.goods_info);
    }
    $scope.go_cartpage=function(){
        $location.path('/pay');
    }
})